package com.weblog.follow.client.factory;


import com.weblog.follow.client.UserClient;
import com.weblog.follow.client.impl.UserClientImpl;

import entity.Result;
import entity.StatusCode;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author MaoLin Wang
 * @date 2019/10/2010:37
 */
@Component
public class UserFallBackFactory implements FallbackFactory<UserClient> {
    @Override
    public UserClient create(Throwable throwable) {
        System.out.println("关注微服务调用用户客户端出错:"+throwable.getMessage()==null?"":throwable.getMessage());
        throwable.printStackTrace();
        return new UserClientImpl() {

            @Override
            public Result fansList(List<String> ids, List<String> iseach) {
                return new Result(false, StatusCode.ERROR,"fansList出错，请稍后再试~");
            }

            @Override
            public Result focusList(List<String> focusList) {
                return new Result(false, StatusCode.ERROR,"focusList出错，请稍后再试~");
            }
        };
    }
}
